// 
// Decompiled by Procyon v0.5.36
// 

package com.cyberfend.cyfsecurity;

import android.os.*;
import android.util.*;
import com.cyberfend.cyfsecurity.b.*;
import java.util.*;

final class k implements java.util.Observer
{
    com.cyberfend.cyfsecurity.j a;
    boolean b;
    long c;
    long d;
    long e;
    java.util.ArrayList<com.cyberfend.cyfsecurity.l> f;
    java.util.ArrayList<com.cyberfend.cyfsecurity.k.a> g;
    java.util.ArrayList<com.cyberfend.cyfsecurity.l> h;
    private float i;
    private float j;
    private float k;
    private float l;
    private float m;
    private float n;
    private float o;
    private float p;
    private float q;
    
    k() {
        this.a = null;
        this.b = false;
        this.c = 0L;
        this.d = 0L;
        this.e = 0L;
        this.f = new java.util.ArrayList<com.cyberfend.cyfsecurity.l>();
        this.g = new java.util.ArrayList<com.cyberfend.cyfsecurity.k.a>();
        this.h = new java.util.ArrayList<com.cyberfend.cyfsecurity.l>();
        this.i = 0.0f;
        this.j = 0.0f;
        this.k = 0.0f;
        this.l = 0.0f;
        this.m = 0.0f;
        this.n = 0.0f;
        this.o = 0.0f;
        this.p = 0.0f;
        this.q = 0.0f;
    }
    
    public final void a() throws java.lang.Exception {
        this.a.a();
        this.a.deleteObservers();
    }
    
    public final com.cyberfend.cyfsecurity.b.b<java.lang.String, java.lang.Long, java.lang.Long> b() {
        try {
            final java.util.ArrayList<java.lang.Object> list;
            (list = new java.util.ArrayList<java.lang.Object>(30)).addAll(this.f);
            list.addAll(this.h);
            final java.util.Iterator<com.cyberfend.cyfsecurity.k.a> iterator = this.g.iterator();
            while (iterator.hasNext()) {
                list.add(iterator.next().a);
            }
            java.util.Collections.<java.lang.Object>sort(list, (java.util.Comparator<? super java.lang.Object>)new com.cyberfend.cyfsecurity.k.b());
            final com.cyberfend.cyfsecurity.i i = new com.cyberfend.cyfsecurity.i();
            java.lang.String string = "";
            long n = 0L;
            long n2 = this.d;
            for (final com.cyberfend.cyfsecurity.l l : list) {
                final com.cyberfend.cyfsecurity.i j = i;
                final com.cyberfend.cyfsecurity.l k = l;
                final long n3 = n2;
                final com.cyberfend.cyfsecurity.l m = k;
                final com.cyberfend.cyfsecurity.i i2 = j;
                final java.lang.String format = j.a.format(m.d);
                final java.lang.String format2 = i2.a.format(m.e);
                final java.lang.String format3 = i2.a.format(m.f);
                final java.lang.String format4 = i2.a.format(m.a);
                final java.lang.String format5 = i2.a.format(m.b);
                final java.lang.String format6 = i2.a.format(m.c);
                final java.lang.String format7 = i2.a.format(m.g);
                final java.lang.String format8 = i2.a.format(m.h);
                final java.lang.String format9 = i2.a.format(m.i);
                long n4;
                if ((n4 = m.j - n3) < 0L) {
                    n4 = 0L;
                }
                final long n5 = n4 + java.lang.Math.round((java.lang.Float.parseFloat(format) + java.lang.Float.parseFloat(format2) + java.lang.Float.parseFloat(format3) + java.lang.Float.parseFloat(format4) + java.lang.Float.parseFloat(format5) + java.lang.Float.parseFloat(format6) + java.lang.Float.parseFloat(format7) + java.lang.Float.parseFloat(format8) + java.lang.Float.parseFloat(format9)) * 100.0f);
                final java.lang.String string2 = n4 + "," + format + "," + format2 + "," + format3 + "," + format4 + "," + format5 + "," + format6 + "," + format7 + "," + format8 + "," + format9 + "," + m.k + ";";
                new java.lang.StringBuilder("Motion string : ").append(string2).append(" time(ms): ").append(android.os.SystemClock.uptimeMillis() - m.j);
                final android.util.Pair pair = new android.util.Pair((java.lang.Object)string2, (java.lang.Object)n5);
                string += (java.lang.String)pair.first;
                n += (long)pair.second;
                n2 = l.j;
            }
            return new com.cyberfend.cyfsecurity.b.b<java.lang.String, java.lang.Long, java.lang.Long>(string, n, this.c);
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.b("MotionManager", "Exception in getting motion events", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
            return new com.cyberfend.cyfsecurity.b.b<java.lang.String, java.lang.Long, java.lang.Long>("", new java.lang.Long(0L), new java.lang.Long(0L));
        }
    }
    
    @java.lang.Override
    public final void update(final java.util.Observable observable, final java.lang.Object data) {
        if (data == null) {
            return;
        }
        try {
            ++this.c;
            final com.cyberfend.cyfsecurity.l l = (com.cyberfend.cyfsecurity.l)data;
            if (this.f.size() < 10) {
                this.f.add(l);
                this.a(l);
            }
            else if ((l.j - this.e >= 1000L || l.k == 2) && this.h.size() < 10) {
                this.h.add(l);
                this.e = l.j;
                this.a(l);
            }
            else {
                final float a;
                if ((a = this.a(l)) != 0.0f) {
                    this.g.add(new com.cyberfend.cyfsecurity.k.a(l, a));
                    if (this.g.size() > 10) {
                        java.util.Collections.<com.cyberfend.cyfsecurity.k.a>sort(this.g);
                        this.g.remove(this.g.size() - 1);
                    }
                }
            }
            if (this.c >= 300L) {
                this.a();
            }
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.b("MotionManager", "Exception in processing motion event", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    private float a(final com.cyberfend.cyfsecurity.l l) {
        final float max = java.lang.Math.max(java.lang.Math.abs(this.i - l.d), java.lang.Math.max(java.lang.Math.abs(this.j - l.e), java.lang.Math.abs(this.k - l.f)));
        this.i = l.d;
        this.j = l.e;
        this.k = l.f;
        final float max2 = java.lang.Math.max(java.lang.Math.abs(this.l - l.a), java.lang.Math.max(java.lang.Math.abs(this.m - l.b), java.lang.Math.abs(this.n - l.c)));
        this.l = l.a;
        this.m = l.b;
        this.n = l.c;
        final float max3 = java.lang.Math.max(java.lang.Math.abs(this.o - l.g), java.lang.Math.max(java.lang.Math.abs(this.p - l.h), java.lang.Math.abs(this.q - l.i)));
        this.o = l.g;
        this.p = l.h;
        this.q = l.i;
        return java.lang.Math.max(max, java.lang.Math.max(max2, max3));
    }
    
    private static final class a implements java.lang.Comparable<com.cyberfend.cyfsecurity.k.a>
    {
        com.cyberfend.cyfsecurity.l a;
        private float b;
        
        public a(final com.cyberfend.cyfsecurity.l a, final float b) {
            this.a = a;
            this.b = b;
        }
    }
    
    final class b implements java.util.Comparator<com.cyberfend.cyfsecurity.l>
    {
    }
}
